import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  Generated,
  UpdateDateColumn,
  OneToMany,
} from 'typeorm'
import { Post } from 'src/post/entities/post.entity'
// import { Commit } from 'src/commit/entities/commit.entity'
@Entity()
export class User {
  @PrimaryGeneratedColumn('uuid') //自动递增的uuid
  id: string
  @Column({ type: 'varchar', length: 16, default: `新ikun` })
  nickname: string
  @Column({ type: 'varchar', length: 11, comment: '手机号', nullable: false })
  mobile: string
  @Column({type:"varchar" ,length:16,nullable:false})
  password:string
  @Column({
    type: 'varchar',
    comment: '头像',
    length: 255,
    nullable: true,
  })
  avatar: string
  @Column({
    type: 'varchar',
    comment: '性别',
    length: 1,
    nullable: true,
  })
  gender: string
  @Column({
    type: 'varchar',
    comment: '邮箱',
    length: 255,
    nullable: true,
  })
  email: string
  @Column({
    type: 'varchar',
    comment: '个签',
    nullable: true,
    length: 255,
  })
  intro: string
  @Column({
    type: 'varchar',
    comment: '标签',
    nullable: true,
    length: 255,
  })
  tags: string
  @Column({
    type: 'varchar',
    nullable: true,
    comment: '注释',
  })
  desc: string

  @OneToMany(() => Post, (post) => post.user)
  posts: Post[]

  @Column({
    type: 'simple-array',
    comment: '关注的人',
    nullable: true,
  })
  follows: string[]
  @Column({
    type: 'simple-array',
    comment: '粉丝',
    nullable: true,
  })
  fans: string[]

  @CreateDateColumn({ type: 'timestamp', update: false, comment: '创建时间' })
  create_time: Date
  @UpdateDateColumn({ type: 'timestamp', update: true, comment: '更新时间' })
  update_time: Date
}
